import { MessageBox } from "element-ui";
export default {
  findValueInObj(array, key) {
    let res = "";
    if (!key) return res;
    array.forEach((element) => {
      if (element.key === key) {
        res = element.value;
      }
    });
    return res;
  },
  findTags(array, uuid) {
    let res = "";
    if (!key) return res;
    array.forEach((element) => {
      if (element.uuid === uuid) {
        res = element.name;
      }
    });
    return res;
  },
  judgeLogin(res) {
    if (res.result === 12) {
      return MessageBox.alert("您的登录已经失效，点击确定重新登录", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          window.location.href = "/admin/#/";
        })
        .catch(() => {
          return Promise.reject();
        });
    }
    return res.file;
  },
};
